import { ProForm, ProFormTextArea, ProFormText, ProFormTreeSelect } from "@ant-design/pro-components"
import { useDictOptions } from "@/hooks";
import { dataCatalogTree } from "@/api/sharing/dataCatalog";

const DataResourceForm = () => {
  const { data: typeOptions } = useDictOptions('data_business_type')

  return <>
    <ProForm.Group rowProps={{
      gutter: 20
    }}>
      <ProForm.Item name='id' hidden></ProForm.Item>
      <ProForm.Item name='accessType' hidden></ProForm.Item>
      <ProForm.Item name='accessUrl' hidden></ProForm.Item>
      <ProForm.Item name='businessId' hidden></ProForm.Item>
      <ProFormText
        name="resourceName"
        label="数据资源名称"
        placeholder="数据资源名称"
        disabled
        rules={[{ required: true, message: '请输入数据资源名称' }]}
      />
      <ProFormText
        name="resourceSign"
        label="数据资源标识"
        placeholder="数据资源标识"
        disabled
        rules={[{ required: true, message: '请输入数据资源标识' }]}
      />
      <ProFormText
        name="publishName"
        label="发布机构名称"
        placeholder="请输入机构名称"
        rules={[{ required: true, message: '机构名称不能为空' }]}
      />
      <ProFormTreeSelect
        name="catalogId"
        label="数据资源目录"
        placeholder="数据资源目录"
        rules={[{ required: true, message: '请选择数据资源目录' }]}
        fieldProps={{
          fieldNames: {
            label: 'catalogName',
            value: 'id',
            children: 'childTreeList',
          }
        }}
        request={() => {
          return dataCatalogTree().then((res) => {
            return res.result || []
          })
        }}
      />
      <ProFormTextArea
        rows={4}
        name="remark"
        label="数据资源描述"
        placeholder="请输入内容"
      />
    </ProForm.Group>
  </>
}

export default DataResourceForm